package com.sochinchou.res.views;

import android.content.Context;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class MyCompoundView extends LinearLayout {
	
	private TextView mTitle;
	private TextView mDialogue;
	private boolean isCollapsed;
	
	public MyCompoundView(Context context, String title, String dialogue) {
		super(context);
		this.setOrientation(VERTICAL);
		
		mTitle = new TextView(context);
		mTitle.setText(title);
		addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

		mDialogue = new TextView(context);
		mDialogue.setText(dialogue);
		addView(mDialogue, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	}

	/**
	 * Convenience method to set the title of a SpeechView
	 */
	public void setTitle(String title) {
		mTitle.setText(title);
	}

	/**
	 * Convenience method to set the dialogue of a SpeechView
	 */
	public void setDialogue(String words) {
		mDialogue.setText(words);
	}

	public void toggle(){
		isCollapsed = !isCollapsed;
		mDialogue.setVisibility(isCollapsed ? VISIBLE : GONE);
	}

	

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if(event.getAction() == MotionEvent.ACTION_UP)
			toggle();
		return true;
		
	}


	
	

}